<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compat ible" content="ie=edge" />
<title>Markmap</title>
<style>
* {
  margin: 0;
  padding: 0;
}
html {
  font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
#mindmap {
  display: block;
  width: 100vw;
  height: 100vh;
}
.markmap-dark {
  background: #27272a;
  color: white;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.12/dist/style.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/styles/default.min.css">
</head>
<body>
<svg id="mindmap"></svg>
<script src="https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js"></script><script src="https://cdn.jsdelivr.net/npm/markmap-view@0.18.12/dist/browser/index.js"></script><script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.18.12/dist/index.js"></script><script>((r) => {
          setTimeout(r);
        })(() => {
  const { markmap, mm } = window;
  const toolbar = new markmap.Toolbar();
  toolbar.attach(mm);
  const el = toolbar.render();
  el.setAttribute("style", "position:absolute;bottom:20px;right:20px");
  document.body.append(el);
})</script><script>((getMarkmap, getOptions, root2, jsonOptions) => {
              const markmap = getMarkmap();
              window.mm = markmap.Markmap.create(
                "svg#mindmap",
                (getOptions || markmap.deriveOptions)(jsonOptions),
                root2
              );
              if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
                document.documentElement.classList.add("markmap-dark");
              }
            })(() => window.markmap,null,{"content":"&#x524d;&#x7aef;&#x77e5;&#x8bc6;&#x6c47;&#x603b;","children":[{"content":"web3.0","children":[{"content":"&#x6982;&#x5ff5;","children":[{"content":"&#x751f;&#x6001;","children":[{"content":"1. &#x53bb;&#x4e2d;&#x5fc3;&#x5316;&#x8eab;&#x4efd;","children":[],"payload":{"tag":"li","lines":"4,5","listIndex":1}},{"content":"2. &#x53bb;&#x4e2d;&#x5fc3;&#x5316;&#x5e94;&#x7528;","children":[],"payload":{"tag":"li","lines":"5,6","listIndex":2}},{"content":"3. &#x53bb;&#x4e2d;&#x5fc3;&#x5316;&#x5b58;&#x50a8;","children":[],"payload":{"tag":"li","lines":"6,7","listIndex":3}},{"content":"4. &#x53bb;&#x4e2d;&#x5fc3;&#x5316;&#x901a;&#x4fe1;&#x548c;&#x8ba1;&#x7b97;","children":[],"payload":{"tag":"li","lines":"7,8","listIndex":4}},{"content":"5. &#x533a;&#x5757;&#x94fe;(&#x96f6;&#x4fe1;&#x4efb;&#x4ea4;&#x4e92;&#x534f;&#x8bae;)&#xff0c;&#x662f;&#x6784;&#x5efa;web3.0&#x7684;&#x57fa;&#x7840;","children":[],"payload":{"tag":"li","lines":"8,9","listIndex":5}}],"payload":{"tag":"h4","lines":"3,4"}},{"content":"&#x5e94;&#x7528;&#x573a;&#x666f;","children":[{"content":"1. ERC2.0","children":[{"content":"1. &#x7a33;&#x5b9a;&#x5e01;&#x3001;&#x4e2d;&#x592e;&#x94f6;&#x884c;&#x6570;&#x5b57;&#x8d27;&#x5e01;","children":[],"payload":{"tag":"li","lines":"11,12","listIndex":1}}],"payload":{"tag":"li","lines":"10,12","listIndex":1}},{"content":"2. ERC721","children":[{"content":"1. &#x4f17;&#x7b79;","children":[],"payload":{"tag":"li","lines":"13,14","listIndex":1}},{"content":"2. &#x516c;&#x8bc1;&#x4e66;","children":[],"payload":{"tag":"li","lines":"14,15","listIndex":2}},{"content":"3. &#x4f9b;&#x5e94;&#x94fe;&#xff1a;&#x900f;&#x660e;&#x6eaf;&#x6e90;&#xff08;&#x725b;&#x5976;&#x751f;&#x4ea7;&#x6d88;&#x8d39;&#x8005;&#xff09;","children":[],"payload":{"tag":"li","lines":"15,16","listIndex":3}},{"content":"4. &#x80a1;&#x6743;&#x8bc1;","children":[],"payload":{"tag":"li","lines":"16,17","listIndex":4}},{"content":"5. &#x521b;&#x9020;&#x8005;&#x7ecf;&#x6d4e;&#xff08;&#x733f;&#x7334;&#xff09;","children":[],"payload":{"tag":"li","lines":"17,18","listIndex":5}},{"content":"6. &#x94fe;&#x6e38;&#xff08;&#x6e38;&#x620f;&#xff09;","children":[],"payload":{"tag":"li","lines":"18,19","listIndex":6}}],"payload":{"tag":"li","lines":"12,19","listIndex":2}}],"payload":{"tag":"h4","lines":"9,10"}},{"content":"&#x6280;&#x672f;&#x6808;","children":[{"content":"1. &#x524d;&#x7aef;react&#x3001;vue","children":[],"payload":{"tag":"li","lines":"20,21","listIndex":1}},{"content":"2. web3.js&#x4e0e;&#x5408;&#x7ea6;&#x4ea4;&#x4e92;&#xff08;&#x4ee5;&#x592a;&#x574a;&#x5f00;&#x53d1;&#xff09;","children":[],"payload":{"tag":"li","lines":"21,22","listIndex":2}},{"content":"3. &#x5408;&#x7ea6;&#x5f00;&#x53d1;","children":[],"payload":{"tag":"li","lines":"22,23","listIndex":3}},{"content":"4. &#x4ee5;&#x592a;&#x574a;&#x865a;&#x62df;&#x673a;EVM","children":[],"payload":{"tag":"li","lines":"23,24","listIndex":4}}],"payload":{"tag":"h4","lines":"19,20"}}],"payload":{"tag":"h3","lines":"2,3"}},{"content":"&#x4ee5;&#x592a;&#x574a;&#xff08;Ethereum&#xff09;","children":[{"content":"&#x6982;&#x5ff5;","children":[{"content":"1. &#x5f00;&#x6e90;&#xff0c;&#x6709;&#x667a;&#x80fd;&#x5408;&#x7ea6;&#x529f;&#x80fd;&#x7684;&#x516c;&#x5171;&#x533a;&#x5757;&#x94fe;&#x5e73;&#x53f0;","children":[],"payload":{"tag":"li","lines":"26,27","listIndex":1}},{"content":"2. &#x901a;&#x8fc7;&#x5176;&#x4e13;&#x7528;&#x8d27;&#x5e01;&#x4ee5;&#x592a;&#x5e01;&#xff08;Ether&#x7b80;&#x79f0;ETH&#xff09;&#x63d0;&#x4f9b;&#x53bb;&#x4e2d;&#x5fc3;&#x5316;&#x7684;&#x4ee5;&#x592a;&#x865a;&#x62df;&#x673a;&#xff08;Etherum Virtual Machine&#xff09;&#x6765;&#x5904;&#x7406;&#x70b9;&#x5bf9;&#x70b9;&#x5408;&#x7ea6;&#x3002;","children":[],"payload":{"tag":"li","lines":"27,28","listIndex":2}}],"payload":{"tag":"h4","lines":"25,26"}},{"content":"&#x6280;&#x672f;&#x5b9e;&#x73b0;","children":[{"content":"1. solidity&#x5b9e;&#x73b0;&#x667a;&#x80fd;&#x5408;&#x7ea6;","children":[],"payload":{"tag":"li","lines":"29,30","listIndex":1}},{"content":"2. web3.js&#x4f7f;&#x7528;JSON-PRC&#xff08;&#x65e0;&#x72b6;&#x6001;&#x3001;&#x8f7b;&#x91cf;&#x7ea7;&#x7684;&#x8fdc;&#x7a0b;&#x8fc7;&#x7a0b;&#x8c03;&#x7528;&#xff08;PRC&#xff09;&#x4f20;&#x9001;&#x534f;&#x8bae;&#xff09;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"34,88\"><code class=\"language-html\">  <span class=\"hljs-meta\">&lt;!doctype <span class=\"hljs-keyword\">html</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html</span> <span class=\"hljs-attr\">lang</span>=<span class=\"hljs-string\">&quot;en&quot;</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta</span> <span class=\"hljs-attr\">charset</span>=<span class=\"hljs-string\">&quot;UTF-8&quot;</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta</span> <span class=\"hljs-attr\">name</span>=<span class=\"hljs-string\">&quot;viewport&quot;</span> <span class=\"hljs-attr\">content</span>=<span class=\"hljs-string\">&quot;width=device-width, initial-scale=1&quot;</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title</span>&gt;</span>Document<span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">title</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script</span> <span class=\"hljs-attr\">src</span>=<span class=\"hljs-string\">&quot;./web3.min.js&quot;</span>&gt;</span><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">script</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">head</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;title&quot;</span>&gt;</span><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">h1</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input</span> <span class=\"hljs-attr\">type</span>=<span class=\"hljs-string\">&quot;text&quot;</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;toAccount&quot;</span> <span class=\"hljs-attr\">placeholder</span>=<span class=\"hljs-string\">&quot;toAccount&quot;</span>&gt;</span>\n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;send&quot;</span>&gt;</span>send<span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">button</span>&gt;</span>\n \n     <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script</span>&gt;</span><span class=\"language-javascript\">\n         <span class=\"hljs-keyword\">const</span> web3 = <span class=\"hljs-keyword\">new</span> <span class=\"hljs-title class_\">Web3</span>(<span class=\"hljs-title class_\">Web3</span>.<span class=\"hljs-property\">givenProvider</span> || <span class=\"hljs-string\">&quot;http://localhost:8545&quot;</span>);\n         <span class=\"hljs-comment\">//&#x8fd4;&#x56de;&#x5f53;&#x524d;&#x533a;&#x5757;&#x53f7;</span>\n         web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">getBlockNumber</span>().<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(res)\n         })\n         <span class=\"hljs-comment\">//&#x8fd4;&#x56de;&#x94fe;&#x63a5;&#x7684;&#x94fe;&#x7684;id&#x53f7;</span>\n         web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">getChainId</span>().<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(res)\n         })\n         <span class=\"hljs-comment\">//</span>\n         <span class=\"hljs-comment\">//&#x901a;&#x8fc7;&#x516c;&#x94a5;&#x8fd4;&#x56de;&#x8d26;&#x53f7;&#x4f59;&#x989d;</span>\n         web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">getBalance</span>(<span class=\"hljs-string\">&apos;0x388ed75240A3f039d48F7b1512ef199373EcEc5E&apos;</span>).<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(web3.<span class=\"hljs-property\">utils</span>.<span class=\"hljs-title function_\">fromWei</span>(res,<span class=\"hljs-string\">&quot;ether&quot;</span>))\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(res)\n         })\n \n         web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">requestAccounts</span>().<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(<span class=\"hljs-string\">&apos;&#x8d26;&#x53f7;&#x6388;&#x6743;&apos;</span>,res)\n             title.<span class=\"hljs-property\">innerHTML</span>= res[<span class=\"hljs-number\">0</span>]\n         })\n         web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">getAccounts</span>().<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n             <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(<span class=\"hljs-string\">&apos;&#x83b7;&#x53d6;&#x8d26;&#x53f7;&apos;</span>,res)\n         })\n \n         <span class=\"hljs-comment\">//</span>\n         send.<span class=\"hljs-property\">onclick</span> = <span class=\"hljs-keyword\">function</span>(<span class=\"hljs-params\"></span>){\n             <span class=\"hljs-comment\">//&#x901a;&#x8fc7;&#x516c;&#x94a5;&#x8f6c;&#x8d26;</span>\n             web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">sendTransaction</span>({\n                 <span class=\"hljs-attr\">from</span>:title.<span class=\"hljs-property\">innerHTML</span>,\n                 <span class=\"hljs-attr\">to</span>:toAccount.<span class=\"hljs-property\">value</span>,\n                 <span class=\"hljs-attr\">value</span>:web3.<span class=\"hljs-property\">utils</span>.<span class=\"hljs-title function_\">toWei</span>(<span class=\"hljs-string\">&quot;1&quot;</span>,<span class=\"hljs-string\">&quot;ether&quot;</span>)\n             }).<span class=\"hljs-title function_\">then</span>(<span class=\"hljs-function\"><span class=\"hljs-params\">res</span>=&gt;</span>{\n                 <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(<span class=\"hljs-string\">&apos;&#x8f6c;&#x597d;&#x4e86;&apos;</span>,res)\n             })\n         }\n     </span><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">script</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">body</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">html</span>&gt;</span>\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"31,89"}}],"payload":{"tag":"li","lines":"30,89","listIndex":2}}],"payload":{"tag":"h4","lines":"28,29"}},{"content":"&#x77ff;&#x5de5;","children":[{"content":"1. A&#x8f6c;B 10ETH,&#x4ed8;&#x8d39;10.1ETH&#xff0c;&#x9700;&#x8981;1&#x8bb0;&#x8d26;&#x5230;&#x516c;&#x94fe;","children":[],"payload":{"tag":"li","lines":"90,91","listIndex":1}},{"content":"2. &#x4ee5;&#x592a;&#x574a;&#x51fa;&#x7b97;&#x6cd5;&#x9898;&#x7ed9;&#x77ff;&#x5de5;&#x8ba1;&#x7b97;","children":[],"payload":{"tag":"li","lines":"91,92","listIndex":2}},{"content":"3. &#x6700;&#x63a5;&#x8fd1;&#x7b54;&#x6848;&#x7684;&#x77ff;&#x5de5;&#x83b7;&#x5f97;&#x8bb0;&#x8d26;&#x6743;&#xff0c;&#x5f97;&#x5230;0.1ETH&#x7684;gas&#x5c0f;&#x8d39;&#xff0c;&#x5c06;&#x8f6c;&#x8d26;&#x8bb0;&#x5f55;&#x5199;&#x5165;&#x516c;&#x94fe;&#x3002;","children":[],"payload":{"tag":"li","lines":"92,93","listIndex":3}}],"payload":{"tag":"h4","lines":"89,90"}}],"payload":{"tag":"h3","lines":"24,25"}},{"content":"MetaMask","children":[{"content":"&#x6982;&#x5ff5;","children":[{"content":"1. &#x662f;&#x4e00;&#x4e2a;&#x6d4f;&#x89c8;&#x5668;&#x63d2;&#x4ef6;&#xff0c;&#x5e76;&#x5728;&#x5f53;&#x524d;&#x7f51;&#x9875;&#x4e2d;&#x6dfb;&#x52a0;window.web3&#x5bf9;&#x8c61;&#xff08;&#x5df2;&#x5e9f;&#x5f03;&#xff09;","children":[],"payload":{"tag":"li","lines":"95,96","listIndex":1}},{"content":"2. &#x5207;&#x6362;&#x4ee5;&#x592a;&#x574a;&#x7b49;&#x7f51;&#x7edc;","children":[],"payload":{"tag":"li","lines":"96,97","listIndex":2}},{"content":"3. &#x5728;&#x5404;&#x79cd;&#x7f51;&#x7edc;&#x4e2d;&#x8fdb;&#x884c;&#x4ea4;&#x6613;&#xff0c;&#x6bd4;&#x5982;&#x4ee5;&#x592a;&#x5e01;&#x6216;ERC20&#x901a;&#x884c;&#x8bc1;","children":[],"payload":{"tag":"li","lines":"97,98","listIndex":3}},{"content":"4. &#x8bb0;&#x4f4f;&#x52a9;&#x8bb0;&#x8bcd;","children":[],"payload":{"tag":"li","lines":"98,99","listIndex":4}},{"content":"5. &#x5b89;&#x5168;&#x6027;&#x4f4e;&#xff0c;&#x6ca1;&#x6709;&#x786c;&#x4ef6;&#x548c;&#x7eb8;&#x94b1;&#x5305;&#x9ad8;&#x3002;","children":[],"payload":{"tag":"li","lines":"99,100","listIndex":5}}],"payload":{"tag":"h4","lines":"94,95"}}],"payload":{"tag":"h3","lines":"93,94"}},{"content":"Truffle","children":[{"content":"Ganache&#x5f00;&#x53d1;&#x73af;&#x5883;&#x5b89;&#x88c5;","children":[{"content":"1. <code>npm i ganache -g</code> &#x6267;&#x884c;&#x5b8c;&#x518d;&#x6267;&#x884c; <code>ganache -d</code>&#xff08;&#x5237;&#x65b0;1000ETH&#xff0c;&#x53bb;&#x6389;-d&#x91cd;&#x7f6e;&#x8d26;&#x53f7;&#xff09;","children":[],"payload":{"tag":"li","lines":"102,103","listIndex":1}},{"content":"2. MetaMask&#x6dfb;&#x52a0;&#x8d26;&#x6237;&#xff1a;&#x4f7f;&#x7528;&#x547d;&#x4ee4;&#x884c;&#x7684;Private Keys&#x6dfb;&#x52a0;&#x5230;&#x94b1;&#x5305;&#x79c1;&#x94a5;","children":[],"payload":{"tag":"li","lines":"103,104","listIndex":2}},{"content":"3. MetaMask&#x6dfb;&#x52a0;&#x94fe;&#xff1a;&#x4f7f;&#x7528;&#x547d;&#x4ee4;&#x884c;&#x7684;RPC Listening&#x5730;&#x5740;&#xff0c;&#x524d;&#x9762;&#x52a0;<code>http:\\\\</code>&#xff0c;Chain&#x7684;ID","children":[],"payload":{"tag":"li","lines":"104,105","listIndex":3}}],"payload":{"tag":"h4","lines":"101,102"}},{"content":"Truffle&#x521d;&#x59cb;&#x5316;&#x9879;&#x76ee;","children":[{"content":"1. <code>npm i truffle -g</code>&#x6267;&#x884c;&#x5b8c;&#x518d;&#x6267;&#x884c;<code>truffle init</code>","children":[{"content":"1. &#x9ed8;&#x8ba4;&#x6587;&#x4ef6;&#x8bf4;&#x660e;&#xff1a;","children":[{"content":"1. <code>contracts</code> &#x5b58;&#x653e;solidity&#x667a;&#x80fd;&#x5408;&#x7ea6;&#x6587;&#x4ef6;","children":[],"payload":{"tag":"li","lines":"108,109","listIndex":1}},{"content":"2. <code>migrations</code> &#x63a7;&#x5236;&#x5408;&#x7ea6;&#x7684;&#x90e8;&#x7f72;","children":[],"payload":{"tag":"li","lines":"109,110","listIndex":2}},{"content":"3. <code>test</code> &#x6d4b;&#x8bd5;&#x6587;&#x4ef6;&#xff08;js/solidity&#xff09;","children":[],"payload":{"tag":"li","lines":"110,111","listIndex":3}},{"content":"4. <code>truffle-config.js</code> &#x914d;&#x7f6e;&#x6587;&#x4ef6;","children":[],"payload":{"tag":"li","lines":"111,112","listIndex":4}}],"payload":{"tag":"li","lines":"107,112","listIndex":1}},{"content":"2. <code>contracts</code>&#x5199;&#x5165;<code>StudentStorage.sol</code>&#x4ee3;&#x7801;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"116,133\"><code class=\"language-text\"> // SPDX-License-Identifier GPL-3.0\n pragma solidity &gt;=0.4.16 &lt;0.9.0;\n\n contract  StudentStorage{\n   uint age;\n   string name;\n   function setData(string calldata _name,uint _age) public{\n     name=_name;\n     age=_age;\n   }\n\n   function getData() public view returns(string memory,uint){\n     return(name,age);\n   }\n }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"113,134"}}],"payload":{"tag":"li","lines":"112,134","listIndex":2}},{"content":"3. &#x914d;&#x7f6e;<code>truffle-config.js</code>&#x6587;&#x4ef6;","children":[{"content":"1. &#x653e;&#x5f00;<code>development</code>","children":[],"payload":{"tag":"li","lines":"135,136","listIndex":1}},{"content":"2. &#x653e;&#x5f00;<code>optimizer</code>&#x548c;<code>evmVersion</code>","children":[],"payload":{"tag":"li","lines":"136,137","listIndex":2}}],"payload":{"tag":"li","lines":"134,137","listIndex":3}},{"content":"4. &#x7f16;&#x8bd1;&#x547d;&#x4ee4;<code>truffle compile</code>","children":[],"payload":{"tag":"li","lines":"137,138","listIndex":4}},{"content":"5. <code>migrations</code>&#x4e0b;<code>1_deploy.js</code>","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"142,148\"><code class=\"language-text\">  const Contacts = artifacts.require(&apos;StudentStorage.sol&apos;)\n  module.exports = function(deployer) {\n    deployer.deploy(Contacts)\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"139,149"}}],"payload":{"tag":"li","lines":"138,149","listIndex":5}},{"content":"6. &#x6267;&#x884c;<code>truffle migrate</code>&#xff08;&#x5f3a;&#x5236;&#x91cd;&#x7f6e;&#x90e8;&#x7f72;<code>truffle migrate --reset</code>&#xff09;","children":[],"payload":{"tag":"li","lines":"149,150","listIndex":6}},{"content":"7. &#x6d4b;&#x8bd5;","children":[{"content":"1. &#x63a7;&#x5236;&#x53f0;&#x6d4b;&#x8bd5;&#xff1a;<code>truffle console</code>","children":[{"content":"1. const obj = await StudentStorage.deployed()","children":[],"payload":{"tag":"li","lines":"152,153","listIndex":1}},{"content":"2. obj.setData(&apos;dapai&apos;,100)","children":[],"payload":{"tag":"li","lines":"153,154","listIndex":2}},{"content":"3. obj.getData()","children":[],"payload":{"tag":"li","lines":"154,155","listIndex":3}}],"payload":{"tag":"li","lines":"151,155","listIndex":1}},{"content":"2. &#x811a;&#x672c;&#x6d4b;&#x8bd5;&#xff1a;&#x6839;&#x76ee;&#x5f55;&#x65b0;&#x5efa;scripts/test.js,&#x6267;&#x884c;<code>truffle exec .\\scripts\\test.js</code>","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"159,170\"><code class=\"language-js\"><span class=\"hljs-keyword\">const</span> <span class=\"hljs-title class_\">Contacts</span> = artifacts.<span class=\"hljs-built_in\">require</span>(<span class=\"hljs-string\">&apos;StudentStorage.sol&apos;</span>)\n<span class=\"hljs-variable language_\">module</span>.<span class=\"hljs-property\">exports</span> = <span class=\"hljs-keyword\">async</span> <span class=\"hljs-keyword\">function</span>(<span class=\"hljs-params\">callback</span>) {\n<span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(<span class=\"hljs-number\">111</span>)\n<span class=\"hljs-keyword\">const</span> studentStorage = <span class=\"hljs-keyword\">await</span> <span class=\"hljs-title class_\">Contacts</span>.<span class=\"hljs-title function_\">deployed</span>()\n<span class=\"hljs-keyword\">await</span> studentStorage.<span class=\"hljs-title function_\">setData</span>(<span class=\"hljs-string\">&apos;daqian&apos;</span>,<span class=\"hljs-number\">100</span>)\n<span class=\"hljs-keyword\">let</span> res = <span class=\"hljs-keyword\">await</span> studentStorage.<span class=\"hljs-title function_\">getData</span>()\n<span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(res)\n <span class=\"hljs-title function_\">callback</span>()\n}\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"156,171"}}],"payload":{"tag":"li","lines":"155,171","listIndex":2}}],"payload":{"tag":"li","lines":"150,171","listIndex":7}},{"content":"8. &#x524d;&#x7aef;&#x8c03;&#x7528;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"175,275\"><code class=\"language-html\">  <span class=\"hljs-meta\">&lt;!doctype <span class=\"hljs-keyword\">html</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html</span> <span class=\"hljs-attr\">lang</span>=<span class=\"hljs-string\">&quot;en&quot;</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta</span> <span class=\"hljs-attr\">charset</span>=<span class=\"hljs-string\">&quot;UTF-8&quot;</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta</span> <span class=\"hljs-attr\">name</span>=<span class=\"hljs-string\">&quot;viewport&quot;</span> <span class=\"hljs-attr\">content</span>=<span class=\"hljs-string\">&quot;width=device-width, initial-scale=1&quot;</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title</span>&gt;</span>Document<span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">title</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script</span> <span class=\"hljs-attr\">src</span>=<span class=\"hljs-string\">&quot;./web3.min.js&quot;</span>&gt;</span><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">script</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">head</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input</span> <span class=\"hljs-attr\">type</span>=<span class=\"hljs-string\">&quot;text&quot;</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;myname&quot;</span>/&gt;</span>\n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input</span> <span class=\"hljs-attr\">type</span>=<span class=\"hljs-string\">&quot;number&quot;</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;myage&quot;</span>/&gt;</span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button</span> <span class=\"hljs-attr\">id</span>=<span class=\"hljs-string\">&quot;add&quot;</span>&gt;</span>add<span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">button</span>&gt;</span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script</span> <span class=\"hljs-attr\">type</span>=<span class=\"hljs-string\">&quot;module&quot;</span>&gt;</span><span class=\"language-javascript\">\n  <span class=\"hljs-keyword\">const</span> web3 = <span class=\"hljs-keyword\">new</span> <span class=\"hljs-title class_\">Web3</span>(<span class=\"hljs-title class_\">Web3</span>.<span class=\"hljs-property\">givenProvider</span> || <span class=\"hljs-string\">&quot;http://localhost:8545&quot;</span>);\n  <span class=\"hljs-keyword\">let</span> account = <span class=\"hljs-keyword\">await</span> web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title function_\">requestAccounts</span>()\n  <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(<span class=\"hljs-string\">&apos;&#x8d26;&#x53f7;&#x6388;&#x6743;&apos;</span>,account)\n  <span class=\"hljs-keyword\">const</span> studentStorage = <span class=\"hljs-keyword\">await</span> <span class=\"hljs-keyword\">new</span> web3.<span class=\"hljs-property\">eth</span>.<span class=\"hljs-title class_\">Contract</span>([\n  {\n   <span class=\"hljs-string\">&quot;inputs&quot;</span>: [],\n   <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;age&quot;</span>,\n   <span class=\"hljs-string\">&quot;outputs&quot;</span>: [\n       {\n           <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>,\n           <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;&quot;</span>,\n           <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>\n       }\n   ],\n  <span class=\"hljs-string\">&quot;stateMutability&quot;</span>: <span class=\"hljs-string\">&quot;view&quot;</span>,\n <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;function&quot;</span>,\n <span class=\"hljs-string\">&quot;constant&quot;</span>: <span class=\"hljs-literal\">true</span>\n },\n {\n    <span class=\"hljs-string\">&quot;inputs&quot;</span>: [],\n  <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;name&quot;</span>,\n <span class=\"hljs-string\">&quot;outputs&quot;</span>: [\n   {\n       <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>,\n        <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;&quot;</span>,\n       <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>\n   }\n ],\n <span class=\"hljs-string\">&quot;stateMutability&quot;</span>: <span class=\"hljs-string\">&quot;view&quot;</span>,\n <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;function&quot;</span>,\n <span class=\"hljs-string\">&quot;constant&quot;</span>: <span class=\"hljs-literal\">true</span>\n },\n {\n  <span class=\"hljs-string\">&quot;inputs&quot;</span>: [\n   {\n       <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>,\n       <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;_name&quot;</span>,\n       <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>\n   },\n   {\n       <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>,\n       <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;_age&quot;</span>,\n       <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>\n     }\n ],\n <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;setData&quot;</span>,\n <span class=\"hljs-string\">&quot;outputs&quot;</span>: [],\n <span class=\"hljs-string\">&quot;stateMutability&quot;</span>: <span class=\"hljs-string\">&quot;nonpayable&quot;</span>,\n <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;function&quot;</span>\n },\n {\n <span class=\"hljs-string\">&quot;inputs&quot;</span>: [],\n <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;getData&quot;</span>,\n <span class=\"hljs-string\">&quot;outputs&quot;</span>: [\n   {\n       <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>,\n       <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;&quot;</span>,\n       <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;string&quot;</span>\n   },\n   {\n       <span class=\"hljs-string\">&quot;internalType&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>,\n       <span class=\"hljs-string\">&quot;name&quot;</span>: <span class=\"hljs-string\">&quot;&quot;</span>,\n       <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;uint256&quot;</span>\n   }\n ],\n <span class=\"hljs-string\">&quot;stateMutability&quot;</span>: <span class=\"hljs-string\">&quot;view&quot;</span>,\n <span class=\"hljs-string\">&quot;type&quot;</span>: <span class=\"hljs-string\">&quot;function&quot;</span>,\n <span class=\"hljs-string\">&quot;constant&quot;</span>: <span class=\"hljs-literal\">true</span>\n }\n  ],<span class=\"hljs-string\">&apos;0x4EE3b17BB418E1c263DaB559405a559100a40f2C&apos;</span>)\n <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(studentStorage) <span class=\"hljs-comment\">//&#x663e;&#x793a;&#x5bf9;&#x8c61;</span>\n add.<span class=\"hljs-property\">onclick</span> =<span class=\"hljs-keyword\">async</span> <span class=\"hljs-keyword\">function</span> (<span class=\"hljs-params\"></span>) {\n  <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(myname.<span class=\"hljs-property\">value</span>,myage.<span class=\"hljs-property\">value</span>)\n <span class=\"hljs-keyword\">await</span> studentStorage.<span class=\"hljs-property\">methods</span>.<span class=\"hljs-title function_\">setData</span>(myname.<span class=\"hljs-property\">value</span>,myage.<span class=\"hljs-property\">value</span>).<span class=\"hljs-title function_\">send</span>({<span class=\"hljs-attr\">from</span>:account[<span class=\"hljs-number\">0</span>]})\n  <span class=\"hljs-title function_\">getDatas</span>()\n }\n <span class=\"hljs-title function_\">getDatas</span>()\n<span class=\"hljs-comment\">//&#x9996;&#x6b21;&#x8fdb;&#x5165;&#x9875;&#x9762;&#x83b7;&#x53d6;&#x5217;&#x8868;</span>\n <span class=\"hljs-keyword\">async</span> <span class=\"hljs-keyword\">function</span> <span class=\"hljs-title function_\">getDatas</span>(<span class=\"hljs-params\"></span>) {\n <span class=\"hljs-keyword\">let</span> res =  <span class=\"hljs-keyword\">await</span> studentStorage.<span class=\"hljs-property\">methods</span>.<span class=\"hljs-title function_\">getData</span>().<span class=\"hljs-title function_\">call</span>()<span class=\"hljs-comment\">//&#x672a;&#x77e5;&#x62a5;&#x9519;&#x4e2d;</span>\n  <span class=\"hljs-variable language_\">console</span>.<span class=\"hljs-title function_\">log</span>(res)\n }\n </span><span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">script</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">body</span>&gt;</span>\n <span class=\"hljs-tag\">&lt;/<span class=\"hljs-name\">html</span>&gt;</span>\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"172,276"}}],"payload":{"tag":"li","lines":"171,276","listIndex":8}}],"payload":{"tag":"li","lines":"106,276","listIndex":1}}],"payload":{"tag":"h4","lines":"105,106"}},{"content":"&#x6574;&#x5408;react","children":[{"content":"1. &#x5c06;&#x9664;&#x4e86;<code>pakage.json</code>&#x548c;<code>node_modules</code>&#x4e00;&#x8d77;&#x62f7;&#x8d1d;&#x5230;react&#x6839;&#x76ee;&#x5f55;&#x4e0b;","children":[],"payload":{"tag":"li","lines":"277,278","listIndex":1}},{"content":"2. &#x91cd;&#x88c5;truffle&#x4e4b;&#x524d;&#x7684;&#x5e93;","children":[],"payload":{"tag":"li","lines":"278,279","listIndex":2}},{"content":"3. &#x5c06;<code>truffle.js</code>&#x6539;&#x4e3a;<code>truffle.cjs</code>,&#x6216;&#x8005;&#x5220;&#x9664;<code>pakage.json</code>&#x7684;<code>type:&quot;moudle&quot;</code>","children":[],"payload":{"tag":"li","lines":"279,280","listIndex":3}}],"payload":{"tag":"h4","lines":"276,277"}}],"payload":{"tag":"h3","lines":"100,101"}}],"payload":{"tag":"h2","lines":"1,2","fold":1}},{"content":"solidity","children":[{"content":"&#x57fa;&#x7840;","children":[{"content":"&#x5f00;&#x59cb;","children":[{"content":"1. https://remix.ethereum.org/","children":[],"payload":{"tag":"li","lines":"283,284","listIndex":1}},{"content":"2. helloworld&#x4ee3;&#x7801;","children":[{"content":"\n<details>\n  <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"288,296\"><code class=\"language-text\">    // SPDX-License-Identifier: MIT\n    pragma solidity 0.8.7;\n \n    contract HelloWorld {\n    string public myStr = &quot;Hello, World!&quot;;\n    }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"285,297"}}],"payload":{"tag":"li","lines":"284,297","listIndex":2}},{"content":"3. &#x9009;&#x62e9;&#x5bf9;&#x5e94;&#x7248;&#x672c;&#x7f16;&#x8bd1;","children":[],"payload":{"tag":"li","lines":"297,298","listIndex":3}},{"content":"4. &#x9009;&#x62e9;deloy","children":[],"payload":{"tag":"li","lines":"298,299","listIndex":4}}],"payload":{"tag":"h4","lines":"282,283"}},{"content":"&#x53d8;&#x91cf;","children":[{"content":"1. values","children":[{"content":"\n<details>\n   <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"304,328\"><code class=\"language-text\">     // ***&#x6c38;&#x4e45;&#x5b58;&#x50a8;&#x5728;&#x94fe;&#x4e0a;&#x7684;&#x53d8;&#x91cf;\n    string public mXyStr = &quot;Hello, World!&quot;;\n    bool public b = true;\n    uint public u = 123;   \n    int public i = -123;\n    int public minInts = type(int).min;\n    int public maxInts = type(int).max;\n    ddress public addr = 0xBD1111111111222;\n    bytes32 public b32 = 0x111111111122222222223333;// keecak256&#x52a0;&#x5bc6;&#x51fd;&#x6570;\n    //***notStateVar&#x4e3a;&#x5c40;&#x90e8;&#x53d8;&#x91cf;\n    function foo() external {\n      uint notStateVar = 456;\n     }\n    //***&#x533a;&#x5757;&#x94fe;&#x7684;&#x5168;&#x5c40;&#x51fd;&#x6570;\n    function viewGlobalInfo() external view returns (address, uint, uint) {\n      address sender = msg.sender;//&#x83b7;&#x53d6;&#x8c03;&#x7528;&#x8be5;&#x65b9;&#x6cd5;&#x7684;&#x7528;&#x6237;&#x5730;&#x5740;\n      uint timestamp = block.timestamp;//&#x8c03;&#x7528;&#x65f6;&#x7684;&#x65f6;&#x95f4;\n      uint blockNum = block.number;//&#x5f53;&#x524d;&#x5757;&#x9ad8;\n      return (sender, timestamp, blockNum);\n  }\n\n  \n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"301,329"}}],"payload":{"tag":"li","lines":"300,329","listIndex":1}},{"content":"2. &#x9ed8;&#x8ba4;&#x503c;","children":[{"content":"\n<details>\n  <summary>&#x9ed8;&#x8ba4;&#x503c;</summary>\n<pre data-lines=\"333,346\"><code class=\"language-text\">   // SPDX-License-Identifier: MIT\n   pragma solidity 0.8.7;\n   // &#x9ed8;&#x8ba4;&#x503c;\n   contract FunctionIntro {\n   string public myStr ;// &apos;&apos;\n   bool public b ; // false\n   uint public u ;// 0\n   int public i ;// 0\n   address public addr;// 0x0000000000000000000000000000000000000000\n   bytes32 public b32 ;//  0x0000000000000000000000000000000000000000000000000000000000000000\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"330,347"}}],"payload":{"tag":"li","lines":"329,347","listIndex":2}},{"content":"3. &#x5e38;&#x91cf;","children":[{"content":"\n<details>\n  <summary>&#x6d88;&#x8017;&#x4e0d;&#x540c;&#x7684;gas</summary>\n<pre data-lines=\"351,359\"><code class=\"language-text\">   contract Constant {\n     string public constant myStr=&apos;abc&apos;;//&#x6d88;&#x8017;733gas\n   }\n   contract Var {\n     string public  myStr1=&apos;abc&apos; ;//&#x6d88;&#x8017;3433gas\n   }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"348,360"}}],"payload":{"tag":"li","lines":"347,360","listIndex":3}},{"content":"4. references&#x5f15;&#x7528;","children":[],"payload":{"tag":"li","lines":"360,361","listIndex":4}}],"payload":{"tag":"h4","lines":"299,300"}},{"content":"&#x65b9;&#x6cd5;","children":[{"content":"1. external &#x5916;&#x90e8;&#x53ef;&#x7528;&#xff0c;&#x5185;&#x90e8;&#x65e0;&#x6cd5;&#x7528;","children":[],"payload":{"tag":"li","lines":"362,363","listIndex":1}},{"content":"2. public &#x5185;&#x5916;&#x90fd;&#x53ef;&#x7528;","children":[],"payload":{"tag":"li","lines":"363,364","listIndex":2}},{"content":"3. internal &#x5916;&#x90e8;&#x4e0d;&#x53ef;&#x7528;&#xff0c;&#x5185;&#x90e8;&#x548c;&#x5185;&#x90e8;&#x6d3e;&#x751f;&#x53ef;&#x7528;","children":[],"payload":{"tag":"li","lines":"364,365","listIndex":3}},{"content":"4. private &#x5185;&#x90e8;&#x53ef;&#x7528;&#xff0c;&#x6d3e;&#x751f;&#x4e0d;&#x53ef;&#x7528;","children":[],"payload":{"tag":"li","lines":"365,366","listIndex":4}}],"payload":{"tag":"h4","lines":"361,362"}},{"content":"&#x5173;&#x952e;&#x5b57;","children":[{"content":"1. external\\pure\\view","children":[{"content":"\n<details>\n  <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"371,388\"><code class=\"language-text\">\n//external &#x5728;&#x7f51;&#x7edc;&#x4e0a;&#x53ef;&#x4ee5;&#x8c03;&#x7528;&#x4ed6;\n//pure &#x53ea;&#x8bfb;&#xff0c;&#x4e14;&#x4e0d;&#x4f9d;&#x8d56;&#x5916;&#x90e8;&#x53d8;&#x91cf;&#xff0c;&#x7eaf;&#x51fd;&#x6570;&#x3002;&#x4e0d;&#x5728;&#x5728;&#x533a;&#x5757;&#x94fe;&#x4e0a;&#x5199;&#x6570;&#x636e;&#xff0c;\nfunction pure1(uint x) external pure returns (uint){ \n        return x+1;\n}\n //view &#x53ea;&#x8bfb;&#xff0c;&#x4f9d;&#x8d56;&#x53d8;&#x91cf;\nfunction view1(uint x) external view returns (uint){ \n        return num-x;\n}\n//&#x4fee;&#x6539;&#x4e86;&#x72b6;&#x6001;&#xff0c;&#x6240;&#x4ee5;&#x4e0d;&#x662f;&#x53ea;&#x8bfb;&#xff0c;&#x65e2;&#x4e0d;&#x80fd;&#x7528;pure&#x4e5f;&#x4e0d;&#x80fd;&#x7528;view\nunit public count =10;\nfunction inc() external {\ncount += 1;\n}\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"368,389"}}],"payload":{"tag":"li","lines":"367,389","listIndex":1}}],"payload":{"tag":"h4","lines":"366,367"}},{"content":"&#x5faa;&#x73af;","children":[{"content":"1. if&#x3001;for&#x3001;while&#x5faa;&#x73af;&#x90fd;&#x6536;gas&#x8d39;&#x7528;","children":[{"content":"\n<details>\n  <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"394,424\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n   pragma solidity 0.8.7;\n   contract ForAndWhileLoops {\n   function loops() external pure{\n   for( uint i = 0; i &lt; 10; i++){\n     // code\n     if (i == 3){\n       continue;\n   }\n   // more code\n   if (i == 5){\n     break;\n     }\n   }\n   uint j = 0;\n   while(j &lt; 10) {\n     // code\n     j ++;\n   }\n  }\n function sum(uint _n) external pure returns(uint){\n uint s;\n for(uint i = 1; i&lt;= _n;i++){\n   s += i;\n }\n return s;\n }\n }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"391,425"}}],"payload":{"tag":"li","lines":"390,425","listIndex":1}}],"payload":{"tag":"h4","lines":"389,390"}},{"content":"&#x9519;&#x8bef;","children":[{"content":"1. require","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"430,435\"><code class=\"language-text\">  function testRequire(uint i) public pure {\n    require(i &lt;= 10, &quot;i is greater than 10&quot;);\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"427,436"}}],"payload":{"tag":"li","lines":"426,436","listIndex":1}},{"content":"2. revert","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"440,447\"><code class=\"language-text\">  function testRevert(uint i) public pure {\n    if (i &gt; 10) {\n      revert(&quot;i is greater than 10&quot;);\n    }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"437,448"}}],"payload":{"tag":"li","lines":"436,448","listIndex":2}},{"content":"3. assert","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"452,458\"><code class=\"language-text\">    uint num = 123;\n    function testAssert() public view {\n      assert(num == 123);//&#x65ad;&#x8a00;123\n    }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"449,459"}}],"payload":{"tag":"li","lines":"448,459","listIndex":3}},{"content":"4. &#x81ea;&#x5b9a;&#x4e49;&#x9519;&#x8bef;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"463,471\"><code class=\"language-text\">  error MyError(address caller, uint i);\n  function testCustomError(uint _i) public view{\n   if(_i &gt; 10){\n     revert MyError(msg.sender, _i);\n   }\n   }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"460,472"}}],"payload":{"tag":"li","lines":"459,472","listIndex":4}}],"payload":{"tag":"h4","lines":"425,426"}},{"content":"&#x4e24;&#x79cd;return","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"476,486\"><code class=\"language-text\">   function named() public pure returns (uint x, bool b){\n     return (1, true);\n  }\n  function assigned() public pure returns (uint x, bool b){\n     // &#x66ff;&#x4ee3;return\n     x = 1;\n     b = true;\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"473,487"}}],"payload":{"tag":"h4","lines":"472,473"}},{"content":"&#x89e3;&#x6784;&#x8d4b;&#x503c;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"491,507\"><code class=\"language-text\"> // SPDX-License-Identifier: MIT\n pragma solidity 0.8.7;\n \n contract FunctionOutputs {\n function returnMany() public pure returns (uint, bool){\n return (1, true);\n }\n \n     function desAssigned() public pure returns (uint x, bool b){\n         (uint x1, bool b1) = returnMany();\n         x = x1;\n         b = b1;\n     }\n }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"488,508"}}],"payload":{"tag":"h4","lines":"487,488"}},{"content":"&#x6570;&#x7ec4;&#xff08;&#x4e0d;&#x8981;&#x5faa;&#x73af;&#x8fd4;&#x56de;&#x6570;&#x7ec4;&#xff0c;&#x82b1;&#x8d39;gas&#xff09;","children":[{"content":"1. &#x56fa;&#x5b9a;&#x3001;&#x975e;&#x56fa;&#x5b9a;&#x6570;&#x7ec4;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"513,517\"><code class=\"language-text\">  uint[] public nums = [1, 2, 3];//&#x975e;&#x56fa;&#x5b9a;&#x957f;&#x5ea6;\n  uint[3] public numsFixed = [4, 5, 6];//&#x56fa;&#x5b9a;&#x957f;&#x5ea6;\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"510,518"}}],"payload":{"tag":"li","lines":"509,518","listIndex":1}},{"content":"2. &#x6570;&#x7ec4;&#x64cd;&#x4f5c;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"522,538\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity 0.8.7;\n\n  contract FunctionOutputs {\n    uint[] public nums = [1, 2, 3];\n    function examples() external {\n      nums.push(4); // [1,2,3,4]\n      uint x = nums[1];\n      nums[2] = 777; // [1, 2, 777, 4]\n      delete nums[1]; // [1, 0, 777, 4]//&#x8bbe;&#x7f6e;&#x4e3a;&#x9ed8;&#x8ba4;&#x503c;\n      nums.pop(); // [1, 0, 777]\n      uint len = nums.length;\n   }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"519,539"}}],"payload":{"tag":"li","lines":"518,539","listIndex":2}},{"content":"3. &#x5185;&#x5b58;&#x6570;&#x7ec4;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"543,549\"><code class=\"language-text\">  function examples() external pure{\n    uint[] memory a = new uint[](5);\n    a[1] = 123;\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"540,550"}}],"payload":{"tag":"li","lines":"539,550","listIndex":3}},{"content":"4. &#x5220;&#x9664;&#x6570;&#x7ec4;+&#x9a8c;&#x8bc1;(&#x591a;gas)","children":[{"content":"1. &#x591a;gas&#x5faa;&#x73af;&#x5220;&#x9664;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"555,578\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity 0.8.7;\n\n  contract FunctionOutputs {\n    uint[] public arr;\n    // [1] -- remove(0) --&gt; [1] --&gt; []\n    // [1, 2, 3] -- remove(1) -- [1, 3, 3 ] --&gt; [1 ,3]\n    // [1, 2, 3, 4, 5, 6] -- remove(2) --&gt; [1, 2, 4, 5, 6, 6] --&gt; [1, 2, 4, 5,6]\n    function remove(uint _index) public {\n      require(_index &lt; arr.length, &quot;index out of bound&quot;);\n      //&#x4ece;index&#x5f00;&#x59cb;&#x5f80;&#x540e;&#x5faa;&#x73af;\n      for(uint i = _index; i &lt; arr.length - 1; i++){\n        arr[i] = arr[i + 1];\n      }\n      arr.pop();\n    }\n    function test() external {\n      arr=[1,2,3,4,5];\n      remove(2);// [1,2,4,5]\n      assert(arr[2] == 4);//&#x9a8c;&#x8bc1;\n    }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"552,579"}}],"payload":{"tag":"li","lines":"551,579","listIndex":1}},{"content":"2. &#x5c11;gas&#x672b;&#x5c3e;&#x66ff;&#x6362;&#x5220;&#x9664;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"583,600\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity 0.8.7;\n\n  contract FunctionOutputs {\n    uint[] public arr;\n    //&#x51cf;&#x5c11;gas&#xff0c;&#x6700;&#x540e;&#x4e00;&#x4f4d;&#x66ff;&#x6362;&#x5220;&#x9664;&#x4f4d;\n    function remove(uint _index) public {\n      arr[_index] = arr[arr.length - 1];\n      arr.pop();\n    }\n    function test() external {\n      arr=[1,2,3,4,5];\n      remove(2);// [1,2,5,4]\n      assert(arr[2] == 5);//&#x9a8c;&#x8bc1;\n    }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"580,601"}}],"payload":{"tag":"li","lines":"579,601","listIndex":2}}],"payload":{"tag":"li","lines":"550,601","listIndex":4}}],"payload":{"tag":"h4","lines":"508,509"}},{"content":"Mapping","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"605,619\"><code class=\"language-text\">  contract FunctionOutputs {\n  mapping(address =&gt; uint) public balances;\n  mapping(address =&gt; mapping(address =&gt; bool)) public isFriend;\n  function examples() external {\n    balances[msg.sender] = 123;\n    uint bal = balances[msg.sender];\n    uint bal2 = balances[address(1)]; // 0\n    balances[msg.sender] = 456; // 456\n    delete balances[msg.sender]; // 0\n     isFriend[msg.sender][address(this)] = true;\n    }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"602,620"}}],"payload":{"tag":"h4","lines":"601,602"}},{"content":"Struct","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"624,657\"><code class=\"language-text\">  contract FunctionOutputs {\n    struct Car {\n      string model;\n      uint year;\n      address owner;\n    }\n    Car public car;\n    Car[] public carArr;\n    mapping(address =&gt; Car[]) public carsByOwner;\n    function examples()external {\n      //&#x7b2c;&#x4e00;&#x79cd;&#x5199;&#x6cd5;\n      Car memory toyota = Car(&quot;Toyota&quot;, 1990, msg.sender);\n      //&#x7b2c;&#x4e8c;&#x79cd;&#x5199;&#x6cd5;\n      Car memory lambo = Car({year: 1980, model: &quot;Lamborghini&quot;, owner:msg.sender});\n      //&#x7b2c;&#x4e09;&#x79cd;&#x5199;&#x6cd5;\n      Car memory tesla;\n      tesla.model = &quot;Tesla&quot;;\n      tesla.year = 2010;\n      tesla.owner = msg.sender;\n\n      carArr.push(toyota);\n      carArr.push(lambo);\n      carArr.push(tesla);\n      carArr.push(Car(&quot;Ferrari&quot;, 2020, msg.sender));\n      // storage &#x5c06;&#x5728;&#x94fe;&#x4e0a;&#x4fee;&#x6539;&#xff0c;memory&#x5728;&#x5185;&#x5b58;&#x4e2d;&#x4fee;&#x6539;\n      Car storage _car = carArr[0];\n      _car.year = 1999;\n      delete _car.owner;//owner&#x88ab;&#x521d;&#x59cb;&#x5316;\n      delete carArr[1];//&#x6574;&#x6761;&#x6570;&#x636e;&#x88ab;&#x521d;&#x59cb;&#x5316;\n    }\n   }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"621,658"}}],"payload":{"tag":"h4","lines":"620,621"}},{"content":"Enum&#x679a;&#x4e3e;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"662,695\"><code class=\"language-text\">   contract FunctionOutputs {\n     enum Status {\n       None,\n       Pending,\n       Shipped,\n       Completed,\n       Rejected,\n       Canceled\n     }\n     Status public status;\n\n     //&#x4f7f;&#x7528;&#x573a;&#x666f;\n     struct Order {\n         address buyer;\n         Status status;\n     }\n     Order[] public orders;\n\n     function get() external view returns (Status){\n       return status;//&#x83b7;&#x53d6;enum&#x7684;&#x503c;\n     }\n     function set(Status _status) external {\n       status = _status;//&#x8bbe;&#x7f6e;enum&#x7684;&#x503c;\n     }\n     function ship() external {\n       status = Status.Shipped;//&#x6539;&#x4e3a;2=Shipped\n     }\n     function reset() external {\n       delete status;//&#x91cd;&#x7f6e;&#x4e3a;0=None\n     }\n   }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"659,696"}}],"payload":{"tag":"h4","lines":"658,659"}},{"content":"storage/memory/calldata","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"700,714\"><code class=\"language-text\"> //storage&#x6c38;&#x4e45;&#x5b58;&#x50a8;&#xff0c;&#x751f;&#x547d;&#x7684;&#x5408;&#x7ea6;&#x53d8;&#x91cf;&#x53ef;&#x4f7f;&#x7528;&#xff0c;&#x6700;&#x591a;gas\n //memory&#x4e34;&#x65f6;&#x5185;&#x5b58;&#xff0c;&#x5c40;&#x90e8;&#x58f0;&#x660e;&#x53ef;&#x4f7f;&#x7528;\n //calldata&#x53ea;&#x8bfb;,&#x51fd;&#x6570;&#x7684;&#x53c2;&#x6570;&#x53ef;&#x4f7f;&#x7528;\n  contract FunctionOutputs {\n    string public text;\n    function set(string calldata _text) external {\n    text = _text;\n    }\n    function get() external view returns (string memory){\n    return text;\n    }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"697,715"}}],"payload":{"tag":"h4","lines":"696,697"}},{"content":"event&#x4e8b;&#x4ef6;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"720,728\"><code class=\"language-text\">   contract Event {\n     event Message(address indexed _from , address indexed _to, string message);\n     function sendMessage(address _to, string calldata message) external {\n       emit Message(msg.sender, _to, message);\n     }\n   }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"717,729"}}],"payload":{"tag":"h4","lines":"715,716"}}],"payload":{"tag":"h3","lines":"281,282","fold":1}},{"content":"&#x88c5;&#x9970;&#x5668;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"733,746\"><code class=\"language-text\">  modifier whenNotPaused(){\n    require(!paused, &quot;paused&quot;);\n    _;\n  }\n  modifier cap(uint _x){\n    require(_x &lt; 100, &quot; x &gt;= 100&quot;);\n    _;\n  }\n  function incBy(uint _x) external whenNotPaused cap(_x) {\n    count += _x;\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"730,747"}}],"payload":{"tag":"h3","lines":"729,730","fold":1}},{"content":"&#x6784;&#x9020;&#x5668;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"751,761\"><code class=\"language-text\"> contract Constructor {\n   address public owner;\n   uint public x;\n   constructor(uint _x) {\n   owner = msg.sender;\n   x = _x;\n   }\n }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"748,762"}}],"payload":{"tag":"h3","lines":"747,748","fold":1}},{"content":"&#x5408;&#x7ea6;","children":[{"content":"1.ERC20","children":[{"content":"1. &#x53ef;&#x66ff;&#x4ee3;&#x4ee3;&#x5e01;&#xff08;Fungible Tokens&#xff09;","children":[{"content":"1. &#x89e3;&#x91ca;&#x53ef;&#x66ff;&#x4ee3;&#x6027;&#x6982;&#x5ff5;&#xff1b;","children":[],"payload":{"tag":"li","lines":"765,766","listIndex":1}}],"payload":{"tag":"li","lines":"764,766","listIndex":1}},{"content":"2. &#x6838;&#x5fc3;&#x529f;&#x80fd;","children":[{"content":"1. totalSupply: &#x603b;&#x4f9b;&#x5e94;&#x91cf;","children":[],"payload":{"tag":"li","lines":"767,768","listIndex":1}},{"content":"2. balancesOf: &#x2f64;&#x2f3e;&#x4f59;&#x989d;&#x6620;&#x5c04;","children":[],"payload":{"tag":"li","lines":"768,769","listIndex":2}},{"content":"3. transfer: &#x8f6c;&#x79fb;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"769,770","listIndex":3}},{"content":"4. approve: &#x6388;&#x6743;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"770,771","listIndex":4}},{"content":"5. transferFrom: &#x6388;&#x6743;&#x8f6c;&#x79fb;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"771,772","listIndex":5}},{"content":"6. allowance:&#x6388;&#x6743;&#x67e5;&#x8be2;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"772,773","listIndex":6}},{"content":"7. mint: &#x589e;&#x53d1;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"773,774","listIndex":7}},{"content":"8. burn: &#x9500;&#x6bc1;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"774,775","listIndex":8}}],"payload":{"tag":"li","lines":"766,775","listIndex":2}},{"content":"3. &#x5e94;&#x7528;&#x573a;&#x666f;","children":[{"content":"1. &#x4ee3;&#x5e01;","children":[],"payload":{"tag":"li","lines":"776,777","listIndex":1}},{"content":"2. &#x7a33;&#x5b9a;&#x5e01; USDT DAI","children":[],"payload":{"tag":"li","lines":"777,778","listIndex":2}},{"content":"3. DeFi &#x7b49;","children":[],"payload":{"tag":"li","lines":"778,779","listIndex":3}}],"payload":{"tag":"li","lines":"775,779","listIndex":3}},{"content":"4. &#x5b9e;&#x4f8b;&#x4ee3;&#x7801;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"783,851\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity ^0.8.0;\n  interface IERC20 {\n     //&#x603b;&#x4f9b;&#x5e94;&#x91cf; totalSupply\n     function totalSupply() external view returns (uint256);\n     //&#x7528;&#x6237;&#x4f59;&#x989d;&#x6620;&#x5c04; balanceOf\n     function balanceOf(address account) external view returns (uint256);\n      //&#x8f6c;&#x79fb;&#x51fd;&#x6570; transfer\n     function transfer(address recipient, uint256 amount) external returns(bool);\n     //&#x6388;&#x6743;&#x67e5;&#x8be2;&#x51fd;&#x6570; allowance\n     function allowance(address owner, address spender) external view returns(uint256);\n     //&#x6388;&#x6743;&#x51fd;&#x6570; approve\n     function approve(address spender, uint256 amount) external returns (bool);\n     //&#x6388;&#x6743;&#x8f6c;&#x79fb;&#x51fd;&#x6570; transferFrom\n      function transferFrom(address sender, address recipient, uint256 amount)external returns (bool);\n     //&#x8f6c;&#x79fb;&#x4e8b;&#x4ef6; Transfer\n     event Transfer(address indexed from, address indexed to, uint256 value);\n     //&#x6388;&#x6743;&#x4e8b;&#x4ef6; Approval\n     event Approval(address indexed owner, address indexed spender, uint256 value);\n  }\n  contract ERC20 is IERC20 {\n     string public name = &quot;TestToken&quot;;\n     string public symbol = &quot;TEST&quot;;\n     uint8 public decimals = 18;\n     uint256 public override totalSupply;//&#x603b;&#x4f9b;&#x5e94;&#x91cf; totalSupply\n     mapping(address =&gt; uint256) public override balanceOf;//&#x7528;&#x6237;&#x4f59;&#x989d;&#x6620;&#x5c04; balanceOf\n     mapping(address =&gt; mapping(address =&gt; uint256)) public override allowance;//&#x6388;&#x6743;&#x67e5;&#x8be2;&#x51fd;&#x6570; allowance\n      //&#x8f6c;&#x79fb;&#x51fd;&#x6570; transfer\n     function transfer(address recipient, uint256 amount) external override returns (bool) {\n         require(balanceOf[msg.sender] &gt;= amount, &quot;Insufficient balance&quot;);\n         balanceOf[msg.sender] -= amount;\n         balanceOf[recipient] += amount;\n         emit Transfer(msg.sender, recipient, amount);\n         return true;\n     }\n     //&#x6388;&#x6743;&#x51fd;&#x6570; approve\n     function approve(address spender, uint256 amount) external override returns (bool) {\n         allowance[msg.sender][spender] = amount;\n         emit Approval(msg.sender, spender, amount);\n         return true;\n     }\n     //&#x6388;&#x6743;&#x8f6c;&#x79fb;&#x51fd;&#x6570; transferFrom\n     function transferFrom(address sender, address recipient, uint256 amount)external override returns (bool) {\n         require(balanceOf[sender] &gt;= amount, &quot;Insufficient balance&quot;);\n         require(allowance[sender][msg.sender] &gt;= amount, &quot;Allowance exceeded&quot;);\n         balanceOf[sender] -= amount;\n         balanceOf[recipient] += amount;\n          allowance[sender][msg.sender] -= amount;\n          emit Transfer(sender, recipient, amount);\n         return true;\n      }\n     //&#x589e;&#x53d1;&#x51fd;&#x6570;\n     function mint(uint256 amount) external {\n         balanceOf[msg.sender] += amount;\n         totalSupply += amount;\n         emit Transfer(address(0), msg.sender, amount);\n     }\n     //&#x9500;&#x6bc1;&#x51fd;&#x6570;\n     function burn(uint256 amount) external {\n         require(balanceOf[msg.sender] &gt;= amount, &quot;Insufficient balance&quot;);\n         balanceOf[msg.sender] -= amount;\n         totalSupply -= amount;\n          emit Transfer(msg.sender, address(0), amount);\n      }\n  }\n\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"780,852"}}],"payload":{"tag":"li","lines":"779,852","listIndex":4}}],"payload":{"tag":"h4","lines":"763,764"}},{"content":"2. ERC721","children":[{"content":"1. &#x4e0d;&#x53ef;&#x66ff;&#x4ee3;&#x4ee3;&#x5e01;&#xff08;Non-Fungible Tokens,NFT&#xff09;","children":[{"content":"1. &#x89e3;&#x91ca;&#x4e0d;&#x53ef;&#x66ff;&#x4ee3;&#x6027;&#x6982;&#x5ff5;","children":[],"payload":{"tag":"li","lines":"854,855","listIndex":1}},{"content":"2. &#x5b9e;&#x4f8b;","children":[],"payload":{"tag":"li","lines":"855,856","listIndex":2}}],"payload":{"tag":"li","lines":"853,856","listIndex":1}},{"content":"2. &#x6838;&#x5fc3;&#x529f;&#x80fd;","children":[{"content":"1. ownerOf: &#x67e5;&#x8be2;ID&#x62e5;&#x6709;&#x8005;","children":[],"payload":{"tag":"li","lines":"857,858","listIndex":1}},{"content":"2. balancesOf: &#x67e5;&#x8be2;&#x62e5;&#x6709;&#x7684;NFT&#x6570;&#x91cf;","children":[],"payload":{"tag":"li","lines":"858,859","listIndex":2}},{"content":"3. transferFrom: &#x8f6c;&#x79fb;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"859,860","listIndex":3}},{"content":"4. approve&#x3001;getAppoved: &#x6388;&#x6743;&#x51fd;&#x6570;","children":[],"payload":{"tag":"li","lines":"860,861","listIndex":4}},{"content":"5. safeTransferFrom: &#x66f4;&#x5b89;&#x5168;&#x7684;&#x8f6c;&#x79fb;&#x65b9;&#x6cd5;&#xff0c;&#x786e;&#x4fdd;&#x63a5;&#x6536;&#x65b9;&#x80fd;&#x63a5;&#x5230;","children":[],"payload":{"tag":"li","lines":"861,862","listIndex":5}}],"payload":{"tag":"li","lines":"856,862","listIndex":2}},{"content":"3. &#x5e94;&#x7528;&#x573a;&#x666f;","children":[{"content":"1. &#x6570;&#x5b57;&#x827a;&#x672f;&#x54c1;","children":[],"payload":{"tag":"li","lines":"863,864","listIndex":1}},{"content":"2. &#x865a;&#x62df;&#x7269;&#x54c1;","children":[],"payload":{"tag":"li","lines":"864,865","listIndex":2}},{"content":"3. &#x865a;&#x62df;&#x571f;&#x5730;&#x7b49;","children":[],"payload":{"tag":"li","lines":"865,866","listIndex":3}}],"payload":{"tag":"li","lines":"862,866","listIndex":3}},{"content":"4. &#x5b9e;&#x4f8b;&#x4ee3;&#x7801;","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"870,1009\"><code class=\"language-text\">   // SPDX-License-Identifier: MIT\n  pragma solidity ^0.8.0;\n  interface IERC165 {\n     function supportsInterface(bytes4 interfaceId) external view returns(bool);\n  }\n  interface IERC721 is IERC165 {\n      event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n      event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n      event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n      function balanceOf(address owner) external view returns (uint256 balance);\n     function ownerOf(uint256 tokenId) external view returns (address owner);\n      function safeTransferFrom(address from, address to, uint256 tokenId)external;\n     function transferFrom(address from, address to, uint256 tokenId) external;\n     function approve(address to, uint256 tokenId) external;\n     function getApproved(uint256 tokenId) external view returns (address operator);\n     function setApprovalForAll(address operator, bool _approved) external;\n     function isApprovedForAll(address owner, address operator) external view returns (bool);\n     function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n  }\n  interface IERC721Receiver {\n     function onERC721Received(address operator, address from, uint256 tokenId,bytes calldata data) external returns (bytes4);\n  }\n  contract ERC721 is IERC721 {\n      mapping(uint256 =&gt; address) private _owners;\n      mapping(address =&gt; uint256) private _balances;\n      mapping(uint256 =&gt; address) private _tokenApprovals;\n      mapping(address =&gt; mapping(address =&gt; bool)) private _operatorApprovals;\n      function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n           return interfaceId == type(IERC721).interfaceId || interfaceId ==\n         type(IERC165).interfaceId;\n     }\n     function balanceOf(address owner) public view virtual override returns (uint256) {\n         require(owner != address(0), &quot;ERC721: balance query for the zero address&quot;);\n         return _balances[owner];\n      }\n      function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n         address owner = _owners[tokenId];\n         require(owner != address(0), &quot;ERC721: owner query for nonexistent token&quot;);\n         return owner;\n      }\n      function approve(address to, uint256 tokenId) public virtual override {\n         address owner = ERC721.ownerOf(tokenId);\n         require(to != owner, &quot;ERC721: approval to current owner&quot;);\n         require(\n             _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n             &quot;ERC721: approve caller is not owner nor approved for all&quot;\n          );\n         _approve(to, tokenId);\n      }\n     function getApproved(uint256 tokenId) public view virtual override returns (address) {\n         require(_exists(tokenId), &quot;ERC721: approved query for nonexistent token&quot;);\n         return _tokenApprovals[tokenId];\n     }\n     function setApprovalForAll(address operator, bool approved) public virtual override {\n         require(operator != _msgSender(), &quot;ERC721: approve to caller&quot;);\n         _operatorApprovals[_msgSender()][operator] = approved;\n         emit ApprovalForAll(_msgSender(), operator, approved);\n     }\n     function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n         return _operatorApprovals[owner][operator];\n     }\n     function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n         require(_isApprovedOrOwner(_msgSender(), tokenId), &quot;ERC721: transfer caller is not owner nor approved&quot;);\n         _transfer(from, to, tokenId);\n     }\n     function safeTransferFrom(address from, address to, uint256 tokenId)public virtual override {\n         safeTransferFrom(from, to, tokenId, &quot;&quot;);\n     }\n     function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\n         require(_isApprovedOrOwner(_msgSender(), tokenId), &quot;ERC721: transfer caller is not owner nor approved&quot;);\n         _safeTransfer(from, to, tokenId, _data);\n     }\n     function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {\n         _transfer(from, to, tokenId);\n         require(_checkOnERC721Received(from, to, tokenId, _data), &quot;ERC721: transfer to non ERC721Receiver implementer&quot;);\n     }\n     function _exists(uint256 tokenId) internal view virtual returns (bool) {\n         return _owners[tokenId] != address(0);\n     }\n     function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n         require(_exists(tokenId), &quot;ERC721: operator query for nonexistent token&quot;);\n         address owner = ERC721.ownerOf(tokenId);\n         return (spender == owner || getApproved(tokenId) == spender ||\n         isApprovedForAll(owner, spender));\n     }\n     function _transfer(address from, address to, uint256 tokenId) internal virtual {\n         require(ERC721.ownerOf(tokenId) == from, &quot;ERC721: transfer of token that is not own&quot;);\n         require(to != address(0), &quot;ERC721: transfer to the zero address&quot;);\n         _approve(address(0), tokenId);\n         _balances[from] -= 1;\n         _balances[to] += 1;\n         _owners[tokenId] = to;\n         emit Transfer(from, to, tokenId);\n     }\n     function _approve(address to, uint256 tokenId) internal virtual {\n         _tokenApprovals[tokenId] = to;\n         emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n     }\n     function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) {\n         if (to.isContract()) {\n             try IERC721Receiver(to).onERC721Received(_msgSender(), from,\n             tokenId, _data) returns (bytes4 retval) {\n                 return retval == IERC721Receiver.onERC721Received.selector;\n             } catch (bytes memory reason) {\n                 if (reason.length == 0) {\n                 revert(&quot;ERC721: transfer to non ERC721Receiver implementer&quot;);\n                 } else {\n                     assembly {\n                         revert(add(32, reason), mload(reason))\n                     }\n                 }\n              }\n         } else {\n             return true;\n         }\n         }\n     function _msgSender() internal view virtual returns (address) {\n         return msg.sender;\n      }\n  }\n  contract MyNFT is ERC721 {\n     function mint(address to, uint256 tokenId) external {\n         require(to != address(0), &quot;ERC721: mint to the zero address&quot;);\n         require(!_exists(tokenId), &quot;ERC721: token already minted&quot;);\n         _balances[to] += 1;\n         _owners[tokenId] = to;\n         emit Transfer(address(0), to, tokenId);\n     }\n     function burn(uint256 tokenId) external {\n         address owner = ERC721.ownerOf(tokenId);\n         require(_msgSender() == owner, &quot;ERC721: burn of token that is not own&quot;);\n         _approve(address(0), tokenId);\n         _balances[owner] -= 1;\n         delete _owners[tokenId];\n         emit Transfer(owner, address(0), tokenId);\n      }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"867,1010"}}],"payload":{"tag":"li","lines":"866,1010","listIndex":4}}],"payload":{"tag":"h4","lines":"852,853"}},{"content":"3. &#x533a;&#x522b;","children":[{"content":"1. &#x53ef;&#x66ff;&#x4ee3;&#x6027;&#xff1a;ERC20&#x53ef;&#x66ff;&#x4ee3;&#xff0c;ERC721&#x4e0d;&#x53ef;&#x66ff;&#x4ee3;","children":[],"payload":{"tag":"li","lines":"1011,1012","listIndex":1}},{"content":"2. &#x5e94;&#x7528;&#x573a;&#x666f;&#xff1a;ERC20&#x7528;&#x4e8e;&#x91d1;&#x878d;&#x652f;&#x4ed8;&#xff0c;ERC721&#x7528;&#x4e8e;&#x6570;&#x5b57;&#x8d44;&#x4ea7;","children":[],"payload":{"tag":"li","lines":"1012,1013","listIndex":2}},{"content":"3. &#x529f;&#x80fd;&#x4fa7;&#x91cd;&#x70b9;&#xff1a;ERC20&#x6279;&#x91cf;&#x8f6c;&#x79fb;&#xff0c;ERC721&#x552f;&#x4e00;&#x6027;&#x7ba1;&#x7406;","children":[],"payload":{"tag":"li","lines":"1013,1014","listIndex":3}}],"payload":{"tag":"h4","lines":"1010,1011"}}],"payload":{"tag":"h3","lines":"762,763","fold":1}},{"content":"&#x9879;&#x76ee;","children":[{"content":"1. &#x7b80;&#x5355;&#x7684;&#x589e;&#x51cf;&#x5408;&#x7ea6;","children":[{"content":"\n<details>\n  <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"1019,1035\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity 0.8.7;\n\n  contract FunctionIntro {\n  uint public count=10;\n  //&#x4fee;&#x6539;&#x4e86;&#x72b6;&#x6001;&#xff0c;&#x6240;&#x4ee5;&#x4e0d;&#x662f;&#x53ea;&#x8bfb;&#xff0c;&#x65e2;&#x4e0d;&#x80fd;&#x7528;pure&#x4e5f;&#x4e0d;&#x80fd;&#x7528;view\n  function inc() external {\n  count += 1;\n  }\n  function dec() external {\n  count -= 1;\n  }\n\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"1016,1036"}}],"payload":{"tag":"li","lines":"1015,1036","listIndex":1}},{"content":"2. &#x62e5;&#x6709;&#x8005;&#x5408;&#x7ea6;","children":[{"content":"\n<details>\n  <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"1040,1065\"><code class=\"language-text\">  // SPDX-License-Identifier: MIT\n  pragma solidity 0.8.7;\n\n  contract Ownable {\n  address public owner;\n  constructor() {\n  owner = msg.sender;\n  }\n  modifier onlyOwner() {\n  require(msg.sender == owner, &quot;not owner&quot;);\n  _;\n  }\n  function setOwner(address _newOwner) external onlyOwner {\n  require(_newOwner != address(0), &quot;invalid address&quot;);\n  owner = _newOwner;\n  } \n  function onlyOwnerCanCallThisFunc() external onlyOwner {\n  // code\n  }\n  function anyOneCanCall() external {\n  // code\n  }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"1037,1066"}}],"payload":{"tag":"li","lines":"1036,1066","listIndex":2}},{"content":"3. todoList","children":[{"content":"\n<details>\n <summary>&#x4ee3;&#x7801;</summary>\n<pre data-lines=\"1070,1098\"><code class=\"language-text\">  contract TodoList {\n    struct Todo {\n    string text;\n    bool completed;\n  }\n  Todo[] public todos;\n  function create(string calldata _text) external {\n    todos.push(Todo({\n      text: _text,\n     completed: false\n    }));\n  }\n  function updateText(uint _index, string calldata _text) external {\n    todos[_index].text = _text;\n     //&#x6b21;&#x6570;&#x591a;&#x53ef;&#x7528;storage&#x8282;&#x7ea6;gas\n     // Todo storage todo = todos[_index];\n     // todo.text= _text;\n  }\n  function get(uint _index) external view returns(string memory, bool) {\n    Todo memory todo = todos[_index];\n    return (todo.text, todo.completed);\n  }\n  function toggleCompleted(uint _index) external {\n    todos[_index].completed = !todos[_index].completed;\n  }\n  }\n</code></pre>\n</details>","children":[],"payload":{"tag":"li","lines":"1067,1102"}}],"payload":{"tag":"li","lines":"1066,1102","listIndex":3}}],"payload":{"tag":"h3","lines":"1014,1015","fold":1}}],"payload":{"tag":"h2","lines":"280,281","fold":1}}],"payload":{"tag":"h1","lines":"0,1"}},null)</script>
</body>
</html>
